package com.nsl.my_youlai.mystar.enums;


import lombok.Data;

import java.util.Arrays;

/**
 * 枚举转化异常
 */
@Data
public class NslEnumTransformException  extends Exception{

    private Object inputObject;
    private Class tClass;

    private String labelRange;


    public NslEnumTransformException(){
        super();
    };

    public NslEnumTransformException(String msg){
        super(msg);
    };

    /**
     *
     * @param inputObject
     * @param tClass
     * @param msg
     */
    public <E extends Enum<E> & NslEnumBaseI> NslEnumTransformException(Object inputObject,Class<E> tClass,String msg){
        super(msg);
        this.inputObject=inputObject;
        this.tClass=tClass;
        System.out.println(Arrays.stream(tClass.getGenericInterfaces()).toList());
        if(!Arrays.stream(tClass.getGenericInterfaces()).toList().toString().contains(NslEnumBaseI.class.getName())){
            throw new RuntimeException("传入class类型，未实现 NslEnumBase 接口");
        }

         this.labelRange=NslEnumBaseI.getLabelRangeAsString(tClass);
//

    }

    public <E extends Enum<E> & NslEnumBaseI> NslEnumTransformException(Object inputObject,Class<E> tClass){
       this(inputObject,tClass,"");
    }
}
